home *** CD-ROM | disk | FTP | other *** search
- Path: news.infi.net!usenet
- From: nngis@norfolk.infi.net (Greg DiGiorgio)
- Newsgroups: comp.lang.c
- Subject: Re: union ?
- Date: 19 Jan 1996 13:32:13 GMT
- Organization: Customer of InfiNet
- Message-ID: <4do6gt$hhr@news.infi.net>
- References: <4dkigi$c29@linet02.li.net>
- Reply-To: nngis@norfolk.infi.net
- NNTP-Posting-Host: h-wastelands.norfolk.infi.net
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.99.3
-
- In article <4dkigi$c29@linet02.li.net>, don@newshost.li.net says...
- >
- >A union consist of many different variables.
- >But at any one time it can only hold one of those variables.
- >Is that correct?
- >
-
- That's correct. A union is an area of shared memory. You define the area
- to be of multiple data types (or variables, if you will). The compiler
- then allocates an area of memory large enough to accommodate that largest
- variable you declared. Then you put data into the union by assigning one
- of the variables a value. Then you can view that value "through the eyes"
- of any of the variables you declared.
-
- Greg DiGiorgio
-
-